/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package clases;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author cbba
 */
public class Hipodromo {

    private static final int CANTIDAD_CABALLOS = 10;
    private static final Meta META = new Meta(100l);
    private List<Caballo> caballos;

    public Hipodromo() {
        this.crearCaballos();
        this.asignarMeta();
        this.correr();
    }

    private void crearCaballos() {
        caballos = new ArrayList<>();
        for (int i = 0; i < CANTIDAD_CABALLOS; i++) {
            caballos.add(new Caballo("Caballo" + i));
        }
    }

    private void asignarMeta() {
        for (Caballo caballo : caballos) {
            caballo.setMeta(this.META);
        }
    }

    private void correr() {
        Thread t;
        for (Caballo caballo : caballos) {
            t = new Thread(caballo);
            t.start();
        }
    }
}
